<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<!-- <script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script> -->
<script src="<?php echo URL::base() ?>media/laydate/laydate.js"></script>
<div class="container-fluid">
    <form class="form-horizontal" method='get' action='<?php echo URL::site(); ?>recievenwarehouse/index'>
        <div class="control-group">
            <label class="control-label">收货日期:</label>
            <div class="controls">
                <input class="input-medium datepicker" type="text"
                	value="<?php if(isset($get['date_from'])) {echo $get['date_from'];} ?>"
                	name='date_from' id="date_from"/>
 			       至 <input class="input-medium datepicker" type="text"
 					name='date_to' id="date_to"
                    value="<?php if(isset($get['date_to'])) {echo $get['date_to'];} ?>"/>
            </div>
        </div>
         <div class="control-group">
            <div class="controls">
                <input class="btn btn-info" type="submit" name="sub" value="查询"/>
                <input class="btn btn-default" type="button" name="downbtn" id="downbtn"
                       value="导出"/>
            </div>
        </div>
    </form>
    <table class="table table-hover ">
        <thead>
        <tr>
            <th>VMI预约单号</th>
            <th>收货单号</th>
            <th>收货明细单号</th>
            <th>收货时间</th>
            <th>SKU</th>
            <th>中文名称</th>
            <th>采购数</th>
            <th>收货数</th>
            <th>质检数</th>
            <th>所属仓库</th>
            <th>收货人</th>
            <th>状态</th>
        </tr>
        </thead>
       <tbody>
    <?php if($show){
        foreach($show as $_show){
        ?>
        <tr>
            <td><?php echo $_show['purchaseorder_id']?></td>
            <td><?php echo $_show['id']?></td>
            <td><?php echo $_show['detail_id']?></td>
            <td><?php echo $_show['recieve_time']?></td>
            <td><?php echo $_show['sku']?></td>
            <td><?php echo $_show['sku_name']?></td>
            <td><?php echo $_show['purchase_quantity']?></td>
            <td><?php echo $_show['arrival_quantity']?></td>
            <td><?php echo $_show['check_count']?></td>
            <td><?php $storeName = '';
                $stores = Kohana::$config->load('vmi_warehouse')->as_array();
                isset($stores[$_show['warehouseid']]) && $storeName = $stores[$_show['warehouseid']];
                echo $storeName;
            ?></td>
            <td><?php echo Erpuser::nick_by_id($_show['recieve_man']);?></td>
            <td>已经收货未质检</td>
        </tr>
    	<?php }
        } elseif($error_msg){?>
        <tr>
            <td colspan="10" style="text-align: center; font-size: large">
                <?php echo $error_msg['msg'];?>
            </td>
        </tr>
    <?php }?>
    </tbody>
</table>
<?php echo $page;?>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        laydate.render({
            elem: '#date_from'
        });
        laydate.render({
            elem: '#date_to'
        });
        $('#downbtn').bind('click', function () {
            var date_from = $("#date_from").val(),
            	date_to = $('#date_to').val();
            window.location.href = "<?php echo URL::base() ?>recievenwarehouse/download?date_from=" + 
            	date_from + "&date_to=" + date_to;
        });
    });
</script>